package hrc.tool.xml;
/**
 * the factory for xmlteller, 
 * you can never build the instance of xmlteller by the constructor of any xmlteller subclass(they are "unaccessible" outside the package)
 * the only way(and safe way) to instance it is to user this factory
 * @author hrc
 */
public class XmlTellerFactory {
	/**
	 * if you have a xml string and want to deal it with by the dom , use it function
	 * @param xml a string that meet the specification of xml language
	 * @return the xmltller instance
	 * @throws XmlException throw is when the xml string is wrong
	 */
	public static XmlTeller createOldStringXmlTeller(String xml) throws XmlException{
		return new OldStringXmlTeller(xml);
	}
	/**
	 * if you have no dom and want to create a new dom and save it to a file,this function is a best choice
	 * @param fileName the file name of the new file you want to create
	 * @param root the root node for the xml dom
	 * @return the xmltller instance
	 * @throws XmlException throw it when create new file fail
	 */
	public static XmlTeller createNewFileXmlTeller(String fileName,String root) throws XmlException{
		return new NewFileXmlTeller(fileName,root);
	}
	/**
	 * if you have a file that store the xml data and want to deal it with ,use it
	 * @param fileName the file name of the old xml file you want to read
	 * @return the xmltller instance
	 * @throws XmlException throw it when fail to read the file
	 */
	public static XmlTeller createOldFileXmlTeller(String fileName) throws XmlException{
		return new OldFileXmlTeller(fileName);
	}
	/**
	 * you have no dom and meraly want to get a xml -type- string
	 * @param root the root node for the xml dom
	 * @return the xmltller instance
	 * @throws XmlException throw it when fail to build a root,that situation handly happen
	 */
	public static XmlTeller createNewStringXmlTeller(String root) throws XmlException{
		return new NewStringXmlTeller(root);
	}
}
